<div class="span12">
    <?php echo $this->Session->flash('carta'); ?>
</div>
<?php
echo $this->element('headerPageTitle', array("titlePage" => "Cartas", "subTitlePage" => "Añadir carta"));
?>
<div class="page secondary">
    <div class="page-region">
        <div class="page-region-content">

            <div class="grid">
                <div class="row">
                    <div class="span6">
                        <div class="hero-unit border-color-blue">
                            <h2>Rellena los datos</h2>

                            <?php echo $this->Form->create('Carta', array('action' => 'add')); ?>

                            <?php
                            echo $this->Form->input('nombre_interno');
                            echo $this->Form->input('nombre_app');
                            echo $this->Form->label('activado', 'Visible');
                            $options = array('0' => 'No', '1' => 'Sí');
                            echo $this->Form->radio('activo', $options, array('legend' => '', 'escape' => false));
                            ?>
                            <?php echo $this->Form->end("Añadir"); ?>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="span8 offset1">

                        <h2>Listado de cartas</h2>
                        <table id="tablaCartas" class="hovered">
                            <thead>
                            <tr>
                                <th>Id</th>
                                <th>Nombre interno</th>
                                <th>Nombre en la Aplicación Móvil</th>
                                <th>Estado</th>

                            </tr>
                            </thead>
                            <tbody>

                            <!-- Here is where we loop through our $posts array, printing out post info -->

                            <?php


                            foreach ($cartas as $carta): ?>
                            <tr>
                                <td><?php echo $carta['Carta']['id']; ?></td>
                                <td><?php echo $carta['Carta']['nombre_interno']; ?></td>
                                <td><?php echo $carta['Carta']['nombre_app']; ?></td>
                                <?php  $activo ='Visible';
                                if ($carta['Carta']['activo'] == '0'){
                                    $activo ='No Visible';
                                }
                                ?>
                                <td><?php echo $activo; ?></td>

                            </tr>
                                <?php endforeach;?>
                            </tbody>


                        </table>


                    </div>
                </div>


                <div class="row">
                    <div class="span8 offset1">


                    </div>
                </div>


            </div>
        </div>
    </div>
</div>
<script>
    $(function() {


        $('#tablaCartas').dataTable({
            "bJQueryUI": true,
            "oLanguage": {
                "sLengthMenu": "Mostrar _MENU_ cartas por página",
                "sZeroRecords": "No existen datos",
                "sInfo": "_START_ al _END_ de _TOTAL_ cartas",
                "sInfoEmpty": "No existen datos",
                "sInfoFiltered": "(filtrado desde _MAX_ total cartas)",
                "sSearch": "Buscar"
            }
        } );


    });
</script>
